<?php

namespace App\Repositories\Transformers;

use App\Models\MeetOrder;
use Carbon\Carbon;
use League\Fractal\TransformerAbstract;

class MeetOrderTransformer extends TransformerAbstract
{
    public function transform(MeetOrder $meetOrder)
    {
        $venueName = '';
        $meetDay = '';
        $durationTime = '';
        // 预约场馆
        $hour = $meetOrder->hour;

        if ($hour) {
            $venueName = $hour->venue->name ?? '';
            $meetDay = $hour->day->day;
            // 时间段
            $durationTime = $hour->start . '~' . $hour->end;

        }
        $meetPerson = [];
        // 预约人
        $person = $meetOrder->person;
        if ($person) {
            $meetPerson['name'] = $person->name;
            $meetPerson['paper_type'] = $person->paper_type;
            $meetPerson['paper'] = $person->paper;
            $meetPerson['audit_status'] = $meetOrder->audit_status;
        }
        return [
            'id' => $meetOrder->id,
            'venue_name' => $venueName,
            'meet_day' => $meetDay,
            'duration_time' => $durationTime,
            'meet_person' => $meetPerson,
        ];

    }
}
